<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
    <div class="container">
        <a class="navbar-brand" href="{:url('index')}">ThinkPHP商城</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav mr-auto">
                <li class="nav-item">
                    <a class="nav-link" href="{:url('index')}">首页</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="{:url('cart')}">购物车</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="{:url('myOrders')}">我的订单</a>
                </li>
            </ul>
            <ul class="navbar-nav ml-auto">
                <?php if (session('user_id')): ?>
                    <li class="nav-item">
                        <a class="nav-link" href="#">欢迎, <?= session('username') ?></a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="{:url('logout')}">退出</a>
                    </li>
                <?php else: ?>
                    <li class="nav-item">
                        <a class="nav-link" href="{:url('login')}">登录</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="{:url('register')}">注册</a>
                    </li>
                <?php endif; ?>
            </ul>
        </div>
    </div>
</nav>